<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>



    <script>

        const p = new Promise((resolve, reject) => {
            const xhr = new XMLHttpRequest();
            xhr.open('get', 'http://121.43.116.41/php/22.php', true);
            xhr.send();
            xhr.onreadystatechange = function () {
                if (xhr.readyState === 4) {
                    if (xhr.status === 200) {
                        resolve(xhr.responseText)
                    }
                    else {
                        reject('响应失败')
                    }
                }
            }
        })



        // 通过then方法调用成功或者失败之后要做的事情
        p.then(
            res => {
                console.log(res);
            },
            err => {
                console.log(err);
            }
        )

    </script>

</body>

</html>